let fs = require("fs");

let file = fs.readFileSync('./default.res.json', {
    encoding: 'utf-8'
});

let ress = JSON.parse(file)['resources'];

let typeDic = {};

let tmpType;
let tmpName;
for (let res of ress) {
    tmpName = res['url'].split('.')[1];
    tmpType = res['type'];
    if (!tmpName) {
        console.log('something wrong' + JSON.stringify(res));
        continue;
    }
    if (!typeDic[tmpName]) {
        typeDic[tmpName] = tmpType;
    }
}

fs.writeFileSync('./genrator_cfg/type_cfg.json',JSON.stringify(typeDic));